( ! echo $@ | grep -q _gprof$$ || echo "(setq compiler::*default-prof-p* t)" >prof_init.lsp ) && \
echo "(system:save-system \"../$@\")" | \
cat ../unixport/init_raw.lsp prof_init.lsp - | \
+ GCL_DISABLE_ASLR=t \
+ GCL_MULTIPROCESS_MEMORY_POOL= \
+ GCL_MEM_BOUND=29 \
GCL_LSPSYSDIR=../$(srcdir)/unixport/ \
../unixport/raw_$* unixport/ -libdir ./ && \
rm -f ../unixport/gcl_cmpnopt.lsp
CLEANFILES+=gcl-tk/demos/index.lsp gcl-tk/demos/gc-monitor.o
gcl-tk/demos/index.lsp: gcl-tk/tkl.o | unixport/saved_gcl
[ -d $(@D) ] || mkdir -p $(@D)
- cd $(@D) && echo "(load \"../../$<\")(tk::get-autoloads (directory \"*.lisp\"))" | ../../$|
+ cd $(@D) && echo "(load \"../../$<\")(tk::get-autoloads)" | ../../$|
sb_cmpnew/gcl_collectfn.o: cmpnew/gcl_collectfn.lsp | unixport/saved_gcl
[ -d $(@D) ] || mkdir -p $(@D)
( ! echo $@ | grep -q _gprof$$ || echo "(setq compiler::*default-prof-p* t)" >prof_init.lsp ) && \
echo "(system:save-system \"../$@\")" | \
cat ../unixport/init_raw.lsp prof_init.lsp - | \
+ GCL_DISABLE_ASLR=t \
+ GCL_MULTIPROCESS_MEMORY_POOL= \
+ GCL_MEM_BOUND=29 \
GCL_LSPSYSDIR=../$(srcdir)/unixport/ \
../unixport/raw_$* unixport/ -libdir ./ && \
rm -f ../unixport/gcl_cmpnopt.lsp
$(word 1,$|) -compile $< -o $@
gcl-tk/demos/index.lsp: gcl-tk/tkl.o | unixport/saved_gcl
[ -d $(@D) ] || mkdir -p $(@D)
- cd $(@D) && echo "(load \"../../$<\")(tk::get-autoloads (directory \"*.lisp\"))" | ../../$|
+ cd $(@D) && echo "(load \"../../$<\")(tk::get-autoloads)" | ../../$|
sb_cmpnew/gcl_collectfn.o: cmpnew/gcl_collectfn.lsp | unixport/saved_gcl
[ -d $(@D) ] || mkdir -p $(@D)
(defun lit-inl2 (form &aux (lf (eq 'lit (car form))))
(list (this-safety-level)
(mapcar (lambda (x) (assert (eq (car x) 'ub)) (third x)) (when lf (fifth form)))
- (cons (when lf (third form)) (info-type (cadr form)))
+ (cons (when lf (third form)) (ensure-known-type (info-type (cadr form))))
(ninth form)
(if lf (remove-comment (fourth form)) "")))
(let ((i -1)) (mapcan (lambda (x &aux (y (incf i))) (unless (atomic-tp x) (list y))) tps))
tr)))
+(defun tr-unused-tps (tr tps &aux (i -1))
+ (mapcar (lambda (x) (if (member (incf i) tr) t x)) tps))
+
(defun ?update-fm-propagator (fm cl tr tps)
(when (symbolp (car cl))
(when (get (car cl) 'type-propagator);?more
(when (eq (car fm) 'lit)
(when (member-if 'integerp tr) ;otherwise no point
- (push (list (car cl) tr tps) (ninth fm)))))))
+ (push (list (car cl) tr (tr-unused-tps tr tps)) (ninth fm)))))))
(defun merge-inl (cl inl pl &aux (tps (pop inl))(tr (pop inl)))
(let ((z (member-if (lambda (x) (can-coalesce x tr inl tps)) (car pl))))
(mapc (lambda (x) (merge-inl cl x pl)) inls))
(defun ?add-inl (cl fms fm)
- (let* ((tps (mapcar (lambda (x) (info-type (caddr x))) fms))
+ (let* ((tps (mapcar (lambda (x) (ensure-known-type (info-type (caddr x)))) fms))
(tr (mapcar (lambda (x &aux (v (car (last x))))
(when (and (consp v) (eq (car v) 'var))
(position (cddr v) fms :key 'cdddr :test 'equalp)));FIXME
(si::string-concatenate "/* " (prin1-to-string form) " */" (remove-comment s))
s))
-(defvar *apply-inl-hash* t)
-
(defun update-info-type-from-inl (i inl fms &aux (tps (mapcar (lambda (x) (info-type (caddr x))) fms)))
(setf (info-type i)
(reduce 'type-and
(mapc (lambda (y) (?update-fm-propagator x y tr (caddr y)))
(sixth inl))))
+(defvar *block-apply-inl* nil)
+
+(defun block-apply-inl (cl)
+ (if (listp *block-apply-inl*)
+ (member (car cl) *block-apply-inl*)
+ t))
-(defun apply-inl (cl fms &aux (inl (when *apply-inl-hash* (inls-match cl fms))))
+(defun apply-inl (cl fms &aux (inl (unless (block-apply-inl cl) (inls-match cl fms))))
(when inl
(let* ((c1fms (mapcar (lambda (x) (cdr (nth x fms))) (second inl))))
(unless (member-if-not (lambda (x)
(defvar *ncompiles* 0)
(defun try-compile (nm s tps
- &aux (*sig-discovery* t)
+ &aux (*sig-discovery* t) si::*sig-discovery-props*
*compile-verbose*
(syms (mapcar (lambda (x) (declare (ignore x)) (gensym)) tps)))
(incf *ncompiles*)
(car inls)))
(defun iterate-over-inls (nm at &optional (it 0)
- &aux (inls (copy-tree (get-inl-list (list nm))))
+ &aux (*block-apply-inl* (list nm))
+ (inls (copy-tree (get-inl-list (list nm))))
(have-2 (member 2 (car inls) :key 'caddr)))
(flet ((try (s tps chg) ;(print (list 'trying nm s (mapcar 'cmp-unnorm-tp tps)))
(print (list nm s (mapcar 'cmp-unnorm-tp tps) chg))
(return-from iterate-over-inls (iterate-over-inls nm at (1+ it))))))
(mapc (lambda (inl &aux (tps (copy-list (car inl))))
+ (try (caddr inl) (car inl) (list 'no-mod))
(when (eql 0 (caddr inl))
(try 1 (car inl) (list 0 '-> 1)))
(mapl (lambda (ptp pstp &aux (tp (car ptp))(stp (car pstp)))
(car inls))
it))
+(defun seed-all-inls (&aux r)
+ (declare (dynamic-extent r))
+ (do-all-symbols (s)
+ (unless (gethash s *inl-hash*)
+ (when (fboundp s)
+ (unless (or (macro-function s) (special-operator-p s))
+ (when (get-return-type s)
+ (unless (member s r)
+ (pushnew s r)
+ (let ((at (get-arg-types s)))
+ (print s)
+ (try-compile s 0
+ (make-list (length (ldiff at (member '* at)))
+ :initial-element t))))))))))
+
(defun finalize-inls (nm &aux (*ncompiles* 0)(at (get-arg-types nm))(inls (get-inl-list (list nm))))
(restrict-inl-1-tps nm at inls)
(list (iterate-over-inls nm at) *ncompiles* (show-inls nm)))
(unless (zerop (car (finalize-inls x)))
(setq redo t)))
*inl-hash*)
- (when redo
- (finalize-all-inls)))
+ (when redo (finalize-all-inls)))
+
+(defun finalize-inl-hash nil
+ (seed-all-inls)
+ (finalize-all-inls))
(defun dump-inl-hash (f &optional finalize &aux (si::*print-package* t))
- (when finalize (finalize-all-inls))
-; (when compress (maphash (lambda (x y) (declare (ignore y)) (compress-inl x)) *inl-hash*))
+ (when finalize (finalize-inl-hash))
(with-open-file (s f :direction :output)
(prin1 '(in-package :compiler) s)
(terpri s)
(si::putprop 'random 'random-propagator 'type-propagator)
(defun lgcd2-propagator (f t1 t2 t3
- &aux (a1 (car (atomic-tp t1)))(a2 (car (atomic-tp t2)))
+ &aux (t1 (type-and #tinteger t1))(t2 (type-and #tinteger t2))(t3 (type-and #tinteger t3))
+ (a1 (car (atomic-tp t1)))(a2 (car (atomic-tp t2)))
(a3 (car (atomic-tp t3))))
(cond ((and a1 a2 a3) (object-type (funcall f a1 a2 a3)))
((type-and #t(not (integer 0 0)) (super-range '* #t(integer 0 1) (super-range 'min t1 t2))))))
; (((t) t) . si::type-of-c)
; (((list) t) . si::cons-car)
; (((list) t) . si::cons-cdr)
+ (((structure) symbol) . structure-name)
(((t t) cons) . cons)
(((*) si::proper-list) . list)
(((t *) list) . list*)
(((real *) (returns-exactly real real)) . ceiling)
(((real *) (returns-exactly real real)) . truncate)
(((real *) (returns-exactly real real)) . round)
+ ((((or (integer 1) (float (0))) *) (or (integer 0) (float 0))) . random)
; (((cons t) cons) . rplaca)
; (((cons t) cons) . rplacd)
; (((symbol) boolean) . boundp)
{
dfprintf(stderr, "guis,vforked child : %d\n", p);
- _exit(p);
+ _exit(0);
/*
return p;
*/
(setf (msg-index) (the fixnum (+ m 1)))
m)
-(defun get-autoloads (&optional (lis (directory "*.lisp")) ( out "index.lsp")
- &aux *paths*
- )
- (declare (special *paths*))
+(defun get-autoloads (&optional
+ (lis (sort (directory "*.lisp") 'string<= :key 'namestring))
+ (out "index.lsp"))
(with-open-file
(st out :direction :output)
(format st "~%(in-package ~s)" (package-name *package*))
(dolist (v lis) (get-file-autoloads v st))
(format st "~%(in-package ~s)" (package-name *package*))
- ;(format st "~2%~s" `(setq si::*load-path* (append ',*paths* si::*load-path*)))
-
- ))
+ (format st "~%(push (namestring (make-pathname :directory (pathname-directory *load-pathname*))) si::*load-path*)")))
&aux (eof '(nil))
(*package* *package*)
saw-package
- name )
- (declare (special *paths*))
+ name)
(setq name (pathname-name (pathname file)))
(with-open-file
(st file)
- (if (boundp '*paths*)
- (pushnew (namestring (make-pathname :directory
- (pathname-directory
- (truename st))))
- *paths* :test 'equal))
(sloop for tem = (read st nil eof)
while (not (eq tem eof))
do (cond ((and (consp tem) (eq (car tem) 'defun))
-"Version_2_7_2pre35"
+"Version_2_7_2pre36"
} while (0)
#ifdef _LP64
-#define C_GC_OFFSET 4
#include <mach-o/x86_64/reloc.h>
#define RELOC_H "mach64_i386_reloc.h"
#else
(a_) = fub; \
} while (0)
-#define C_GC_OFFSET 4
#include <mach-o/arm64/reloc.h>
#define RELOC_H "mach64_aarch64_reloc.h"
#define I386
#define SGC
-/* Apparently stack pointers can be 4 byte aligned, at least &argc -- CM */
-#define C_GC_OFFSET 4
-
#define RELOC_H "elf64_i386_reloc.h"
#define BRK_DOES_NOT_GUARANTEE_ALLOCATION
#define I386
#define SGC
-/* Apparently stack pointers can be 4 byte aligned, at least &argc -- CM */
-#define C_GC_OFFSET 4
-
#define RELOC_H "elf64_i386_reloc.h"
#define MAX_CODE_ADDRESS (1L<<31)/*large memory model broken gcc 4.8*/
#define MAX_DEFAULT_MEMORY_MODEL_CODE_ADDRESS (1UL<<31)
#ifdef UNIX
EXTER char **ENVP;
#endif
+EXTER struct stat ss;
EXTER object sSAsystem_directoryA;
#ifdef UNIX
#define SGC
-/* Apparently stack pointers can be 4 byte aligned, at least &argc -- CM */
-#define C_GC_OFFSET 4
-
#define RELOC_H "elf64_loongarch64_reloc.h"
#define SPECIAL_RELOC_H "elf64_loongarch64_reloc_special.h"
/* #define MAX_CODE_ADDRESS (1L<<31)/\*large memory model broken gcc 4.8*\/ */
if (pool==-1) {
- struct stat ss;
massert(!lstat(multiprocess_memory_pool,&ss));
massert(S_ISDIR(ss.st_mode));
#define SPECIAL_RELOC_H "elf64_ppcle_reloc_special.h"
#endif
#define OUTPUT_MACH bfd_mach_ppc64
-#define C_GC_OFFSET 4
#endif
int msbrk_initialized(void);
void *mdlopen(const char *,int);
void set_global_env_defaults(void);
-void disable_aslr(int,char **,char **);
+void maybe_disable_aslr(int,char **,char **);
void set_leak_malloc_on(void);
void set_leak_malloc_off(void);
#define SGC
-/* Apparently stack pointers can be 4 byte aligned, at least &argc -- CM */
-#define C_GC_OFFSET 4
-
#define RELOC_H "elf64_riscv64_reloc.h"
/* #define MAX_CODE_ADDRESS (1L<<31)/\*large memory model broken gcc 4.8*\/ */
#define SGC
#if SIZEOF_LONG == 8
-#define C_GC_OFFSET 4
#define RELOC_H "elf64_s390_reloc.h"
#define SPECIAL_RELOC_H "elf64_sparc_reloc_special.h"
#define OUTPUT_MACH bfd_mach_s390_64
#define SPECIAL_RELOC_H "elf64_sparc_reloc_special.h"
#endif
-/* #if SIZEOF_LONG == 8 */
-/* #define C_GC_OFFSET 4 */
-/* #endif */
-
#define OUTPUT_MACH bfd_mach_sparc_v9
return find_init_string(tmp);
#else
- struct stat ss;
char *tmp,*q;
FILE *f;
#include "include.h"
-#ifdef DISABLE_ASLR
-
#if defined(__APPLE__)
#include <stdio.h>
#endif
void
-disable_aslr(int argc, char **argv, char **envp) {
+maybe_disable_aslr(int argc, char **argv, char **envp) {
pid_t pid;
posix_spawnattr_t attr;
+#ifndef DISABLE_ASLR
+ if (!getenv("GCL_DISABLE_ASLR"))
+ return;
+#endif
+
if (!_dyld_get_image_vmaddr_slide(0)) {
return;
}
#include <unistd.h>
void
-disable_aslr(int argc, char **argv, char **envp) {
+maybe_disable_aslr(int argc, char **argv, char **envp) {
long pers;
long flag = ADDR_NO_RANDOMIZE|(sizeof(flag)==4 ? ADDR_COMPAT_LAYOUT : 0);
+#ifndef DISABLE_ASLR
+ if (!getenv("GCL_DISABLE_ASLR"))
+ return;
+#endif
+
massert((pers=personality(-1))!=-1);
/*READ_IMPLIES_EXEC is for selinux, but selinux will reset it in the child*/
#include <sys/procctl.h>
void
-disable_aslr(int argc, char **argv, char **envp) {
+maybe_disable_aslr(int argc, char **argv, char **envp) {
const int cctl=PROC_ASLR_FORCE_DISABLE;
int stat,ctl=cctl;
+#ifndef DISABLE_ASLR
+ if (!getenv("GCL_DISABLE_ASLR"))
+ return;
+#endif
+
massert(procctl(P_PID, 0, PROC_ASLR_STATUS, &stat) != -1);
if ((stat&cctl)!=cctl && !getenv("GCL_UNRANDOMIZE")) {
#else /*Unneeded on Hurd, cygwin/mingw via coff header flag*/
void
-disable_aslr(int argc, char **argv, char **envp) {
+maybe_disable_aslr(int argc, char **argv, char **envp) {
return;
}
#endif
#endif
-
-#endif
if (!(fp=*FN1=='|' ? popen(FN1+1,"r") : fopen_not_dir(FN1,"r")) && sSAallow_gzipped_fileA->s.s_dbind!=Cnil) {
- struct stat ss;
massert(snprintf(FN2,sizeof(FN2),"%s.gz",FN1)>0);
if (!stat(FN2,&ss)) {
+#include <dlfcn.h>
+
#include "include.h"
#include "page.h"
#include "ptable.h"
-
static unsigned long gprof_on;
+static void (*real_mcount)(void);
+
+void __attribute__((no_instrument_function))
+mcount(void) {
+
+ if (__builtin_expect(!gprof_on,1))
+ return;
+
+ real_mcount();
+
+}
/*all but this stub to be written in the future provided*/
#if defined(__APPLE__)
return Cnil;
writable_malloc_wrap(my_monstartup,int,start,end);
+ if (__builtin_expect(!real_mcount,0))
+ massert(real_mcount=dlsym(RTLD_NEXT,"mcount"));
gprof_on=1;
return Ct;
gprof_cleanup(void) {
FFN(fSmcleanup)();
+ real_mcount=NULL;
}
ufixhash(ufixnum g) {
ufixnum i,h;
for (h=i=0;i<sizeof(g);g>>=CHAR_SIZE,i++)
- h^=rtb[g&MASK(CHAR_SIZE)];
+ h^=rtb[(g+i)&MASK(CHAR_SIZE)];
return h;
}
for (;u<ue;) {
ufixnum v=(*u++)>>s;
- if (u<ue||m) {
+ if (s&&(u<ue||m)) {
ufixnum w=(*u);
if (u==ue)
w&=BIT_MASK(m);
- v|=w<<(sizeof(*u)-s);
+ v|=w<<(BV_BITS-s);
}
h^=ufixhash(v);
}
for (;u<ue;) {
ufixnum v=(*u++)>>s;
- if (u<ue||m) {
+ if (s&&(u<ue||m)) {
ufixnum w=(*u);
if (u==ue)
w&=BIT_MASK(m);
- v|=w<<(sizeof(*u)-s);
+ v|=w<<(BV_BITS-s);
}
h^=ufixhash(v);
}
}
multiprocess_memory_pool=getenv("GCL_MULTIPROCESS_MEMORY_POOL");
+ if (multiprocess_memory_pool && !*multiprocess_memory_pool)
+ multiprocess_memory_pool=NULL;
if (multiprocess_memory_pool &&
(*multiprocess_memory_pool=='t' || *multiprocess_memory_pool=='T'))/*GCL 2.6 compatability*/
multiprocess_memory_pool=getenv("HOME");
int
main(int argc, char **argv, char **envp) {
-#ifdef DISABLE_ASLR
- disable_aslr(argc,argv,envp);
-#endif
+ maybe_disable_aslr(argc,argv,envp);
#include "cstack.h"
set_global_env_defaults();
shared_lib_start=NULL;
memset(&fcall,0,sizeof(fcall));
+ memset(&ss,0,sizeof(ss));
memset(gmp_jmp,0,sizeof(gmp_jmp));
memset(stdin_buf,0,sizeof(stdin_buf));
memset(stdout_buf,0,sizeof(stdout_buf));
FILE *
fopen_not_dir(char *filename,char *option) {
- struct stat ss;
-
return DIR_EXISTS_P(filename,ss) ? NULL : fopen(filename,option);
}
int
file_len(FILE *fp) {/*FIXME dir*/
- struct stat filestatus;
-
- return fstat(fileno(fp), &filestatus) ? 0 : filestatus.st_size;
+ return fstat(fileno(fp), &ss) ? 0 : ss.st_size;
}
bool
file_exists(object x) {
- struct stat ss;
-
coerce_to_filename(x,FN1);
return FILE_EXISTS_P(FN1,ss) ? TRUE : FALSE;
DEFUN("STAT1",object,fSstat1,SI,1,1,NONE,OO,OO,OO,OO,(object x),"") {
- struct stat ss;
-
RETURN1(stat_internal(x,&ss) ? stat_mode_key(&ss) : Cnil);
}
object *vals=(object *)fcall.valp;
object *base=vs_top;
- struct stat ss;
if (stat_internal(x,&ss))
RETURN4(stat_mode_key(&ss),
#define get_d_type(e,s) e->d_type
#else
#define get_d_type(e,s) \
- ({struct stat ss;\
- massert(snprintf(FN1,sizeof(FN1),"%-*.*s%s",s->st.st_fillp,s->st.st_fillp,s->st.st_self,e->d_name)>=0);\
+ ({massert(snprintf(FN1,sizeof(FN1),"%-*.*s%s",s->st.st_fillp,s->st.st_fillp,s->st.st_self,e->d_name)>=0);\
lstat(FN1,&ss);S_ISDIR(ss.st_mode) ? DT_DIR : DT_REG;})
#endif
int n;
void *v1;
- struct stat ss;
massert((n=fileno(fp))>2);
massert(!fstat(n,&ss));
static void
ar_init_fn(void (fn)(void),const char *s) {
- struct stat ss;
-
if (stat(s,&ss)) {
char *sysd=getenv("GCL_SYSDIR");